package cn.tj.service.impl;

import cn.tj.entity.PageBean;
import cn.tj.entity.Technician;
import cn.tj.mapper.TechnicianMapper;
import cn.tj.service.TechnicianService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TechnicianServiceImpl implements TechnicianService {
    @Autowired
    private TechnicianMapper technicianMapper;

    @Override
    public PageBean listByPage(Integer currentPage, Integer pageSize, Integer typeId, String name) {
        PageBean<Object> pg = new PageBean<>();

        PageHelper.startPage(currentPage,pageSize);
        List<Technician> tList = technicianMapper.listByPage(typeId,name);

        Page p=(Page) tList;

        pg.setItems(p.getResult());
        pg.setTotal(p.getTotal());
        return pg;
    }

    @Override
    public Technician getById(Integer id) {
        return technicianMapper.getById(id);
    }

    @Override
    public void editById(Technician technician) {
        technicianMapper.editById(technician);
    }

    @Override
    public void add(Technician technician) {
        technicianMapper.add(technician);
    }

    @Override
    public void deleteById(Integer id) {
        technicianMapper.deleteById(id);
    }
}
